import React, { Component } from 'react';
import { connect } from 'dva';

import { Layout, } from 'antd';
// 侧边栏
import Aside from './components/Aside';
// 头部
import Head from './components/Head';

import styles from './index.less';
import handleStorage from '../utils/handleStorage';

const { Content } = Layout;
@connect((state) =>
({
})
)
// 公共组件布局
class BasicLayout extends Component {

  componentWillMount() {
    // this.props.history.push('/map');
  }

  // 刷新页面就重定向回首页
  componentDidMount() {
    this.initUser();
  }

  initUser = () => {
    const uid = handleStorage.getStorage('gis-user');
    this.props.dispatch({
      type: 'layout/getUserDetail',
      payload: {
        uid
      }
    })
  }

  render() {
    return (
      <Layout className={styles.layout} >
        <Head />
        <Layout>
          <Aside />
          <Layout>
            <Content
              style={{
                background: '#fff',
                padding: 5,
                minHeight: 280,
              }}
            >
              {this.props.children}
            </Content>
          </Layout>
        </Layout >
      </Layout >
    );
  }
}

BasicLayout.wrappers = ['@/utils/auth']

export default BasicLayout;
